package com.mediocre.api.controller;

import com.mediocre.api.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
class TestController {
    @Autowired
    private TestService testService;

    /**
     * 1 实现限流控制
     * @return
     */
    @GetMapping("/hello")
    public String hello() {
        testService.doSomething("hello " + new Date());
        return "hello, doSomething";
    }

    /**
     * 2 实现限流的异常处理
     * @return
     */
    @GetMapping("/hello2")
    public String hello2() {
        testService.doSomeThing2("hello2 " + new Date());
        return "hello, doSomething2";
    }

    /**
     * 3 实现熔断降级
     * @return
     */
    @GetMapping("/hello3")
    public String hello3() {
        testService.doSomeThing3("hello3 " + new Date());
        return "hello, doSomething3";
    }
}
